package com.jichangxiu.socket.action;

import com.jichangxiu.common.annotation.Get;
import com.jichangxiu.common.annotation.Rest;
import com.jichangxiu.common.entity.bo.Record;
import com.jichangxiu.framework.action.BaseAction;
import com.jichangxiu.framework.utils.SecurityUtils;
import com.jichangxiu.socket.entity.SocketResult;
import com.jichangxiu.socket.enums.SocketPage;
import com.jichangxiu.socket.enums.SocketType;
import com.jichangxiu.socket.utils.SocketUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * TestSocketAction:
 *
 * @author Jcx
 * @create 2024-04-09 20:58
 */
@Rest("/test/socket")
@Tag(name = "测试-Socket控制器")
public class TestSocketAction extends BaseAction {

    @Operation(summary = "发给 index 的消息")
    @Get("/index")
    public String index() {
        SocketUtils.self.notify.sendSuccessNotify(SocketPage.INDEX.getPage(), "你好，世界，Index！");
        SocketUtils.send(SocketResult.syncSocketResult(Record.getRecord("index", "你好，世界！"), SocketPage.INDEX.getPage(), SocketType.MESSAGE.getType()));
        return "index";
    }

    @Operation(summary = "消息提示")
    @Get("/msg")
    public String msg() {
        SocketUtils.self.msg.sendMsg("你好，世界！");
        return "msg";
    }

    @Operation(summary = "错误消息提示")
    @Get("/errorMsg")
    public String errorMsg() {
        SocketUtils.self.msg.sendErrorMsg("你好，世界！");
        return "errorMsg";
    }

    @Operation(summary = "成功消息提示")
    @Get("/successMsg")
    public String successMsg() {
        SocketUtils.self.msg.sendSuccessMsg("你好，世界！");
        return "successMsg";
    }

    @Operation(summary = "警告消息提示")
    @Get("/warningMsg")
    public String warningMsg() {
        SocketUtils.self.msg.sendWarningMsg("你好，世界！");
        return "warningMsg";
    }

    @Operation(summary = "弹出提示")
    @Get("/alert")
    public String alert() {
        SocketUtils.sync.alert.sendAlert("你好，世界！");
        return "alert";
    }

    @Operation(summary = "弹出错误提示")
    @Get("/errorAlert")
    public String errorAlert() {
        SocketUtils.sync.alert.sendErrorAlert("你好，世界！");
        return "errorAlert";
    }

    @Operation(summary = "弹出成功提示")
    @Get("/successAlert")
    public String successAlert() {
        SocketUtils.sync.alert.sendSuccessAlert("你好，世界！");
        return "successAlert";
    }

    @Operation(summary = "弹出警告提示")
    @Get("/warningAlert")
    public String warningAlert() {
        SocketUtils.sync.alert.sendWarningAlert("你好，世界！");
        return "warningAlert";
    }

    @Operation(summary = "通知提示")
    @Get("/notifies")
    public String notifies() {
        SocketUtils.async.notify.sendNotify(SecurityUtils.getUserInfo().getUserId(), "1728408367672741988", "你好，世界！");
        return "notifies";
    }

    @Operation(summary = "错误通知提示")
    @Get("/errorNotify")
    public String errorNotify() {
        SocketUtils.async.notify.sendErrorNotify(SecurityUtils.getUserInfo().getUserId(), "1728408367672741988", "你好，世界！");
        return "errorNotify";
    }

    @Operation(summary = "成功通知提示")
    @Get("/successNotify")
    public String successNotify() {
        SocketUtils.async.notify.sendSuccessNotify(SecurityUtils.getUserInfo().getUserId(), "1728408367672741988", "你好，世界！");
        return "successNotify";
    }

    @Operation(summary = "警告通知提示")
    @Get("/warningNotify")
    public String warningNotify() {
        SocketUtils.async.notify.sendWarningNotify(SecurityUtils.getUserInfo().getUserId(), "1728408367672741988", "你好，世界！");
        return "warningNotify";
    }

}
